/**
 * Created by dev-001 on 2017/3/27.
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const OrderSchema = new Schema({
    clazz: {
        type: ObjectId,
        ref: 'Clazz'
    },
    subject: {
        type: ObjectId,
        ref: 'Subject'
    },
    teacher: {
        type: ObjectId,
        ref: 'Teacher'
    },
    startedAt: Date,
    endedAt: Date,
    createdAt: Date,
    updatedAt: Date
});

OrderSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Order', OrderSchema);